/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-08-22
 * Time: 15:45
 */
class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("这是用继承，重写run");
    }
}

class MyRunnable implements Runnable{
    @Override
    public void run() {
        System.out.println("这是实现Runnable,重写run");
    }
}

public class Test {
    public static void main(String[] args) {
        Thread t1=new MyThread();
        t1.start();

        MyRunnable myRunnable=new MyRunnable();
        Thread t2=new Thread(myRunnable);
        t2.start();

        Thread t3=new Thread(){
            @Override
            public void run() {
                System.out.println("这是使用Thread的匿名内部类，重写run");
            }
        };
        t3.start();

        Runnable runnable=new Runnable(){
            @Override
            public void run() {
                System.out.println("这是使用Runnable的匿名内部类，重写run");
            }
        };
        Thread t4=new Thread(runnable);
        t4.start();

        Thread t5=new Thread( ()->{
            System.out.println("这是使用lambda表达式，重写run");
        } );
        t5.start();
    }
}
